<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html" ; charset="utf-8" />
    <title>宏宇教育信息采集</title>
    <link href="../../../css/main.css" rel="stylesheet" type="text/css">
    <link href="../../../bstable/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="../../../bstable/css/bootstrap-table.css" rel="stylesheet" type="text/css">
    <link href="../../../layer_v2.1/layer/skin/layer.css" rel="stylesheet" type="text/css">
    <link href="../../../css/new.css" rel="stylesheet" type="text/css">

</head>

<body>
    <!-- <div class="lx-top">
        宏宇教育信息采集
    </div> -->

    <div class="lx-section">
        <div class="title">
            基本信息
        </div>
        <div class="lx-form">
            <div class="p_line text_ient lx-row">
                <p class="col lx-col-50">
                    <a class="find_a"><span style="color:red">*</span> 姓名：</a>
                    <input id="name" type="text" maxlength="10" class="form_input text_ient" />
                </p>
                <p class="col lx-col-50">
                    <a class="find_a"><span style="color:red">*</span>身份证号：</a>
                    <input id="idno" type="text" maxlength="18" class="form_input text_ient" />
                </p>
            </div>
            <div class="p_line text_ient lx-row ptb10">
                <div class="col lx-col-50">
                    <a class="find_a">身份证正面：</a>
                    <p class="img-con front-con">
                        <img src="">
                        <b class="del-img">❌</b>
                    </p>
                    <input id="id-front" type="file" class="input-file" accept="image/*" />
                </div>
                <div class="col lx-col-50">
                    <a class="find_a">身份证反面：</a>
                    <p class="img-con">
                        <img src="">
                        <b class="del-img">❌</b>
                    </p>
                    <input id="id-back" type="file" class="input-file" accept="image/*" />
                </div>
            </div>
            <div class="p_line text_ient lx-row">
                <p class="col lx-col-25">
                    <a class="find_a"><span style="color:red">*</span>电话：</a>
                    <input id="phone" type="text" maxlength="11"  class="form_input text_ient" />
                </p>
                <p class="col lx-col-25">
                    <a class="find_a">民族：</a>
                    <input id="nation" type="text" class="form_input text_ient" />
                </p>
                <p class="col lx-col-25">
                    <a class="find_a">性别：</a>
                    <input id="sex" type="text"  class="form_input text_ient" />
                </p>
                <p class="col lx-col-25">
                    <a class="find_a">生日：</a>
                    <input type="date" id="birth" class="form_input text_ient" />
                </p>
            </div>
            <div class="p_line text_ient lx-row">
                <p class="col lx-col-100">
                    <a class="find_a">住址：</a>
                    <input type="text" id="address" class="form_input text_ient" />
                </p>
            </div>
            <div class="p_line text_ient lx-row">
                <p class="col lx-col-33">
                    <a class="find_a">邮箱：</a>
                    <input id="email" type="text" maxlength="20" class="form_input text_ient" />
                </p>
                <p class="col lx-col-33">
                    <a class="find_a">QQ：</a>
                    <input id="qq" type="text" maxlength="13" class="form_input text_ient" />
                </p>
                <p class="col lx-col-33">
                    <a class="find_a">工作单位：</a>
                    <input id="company" type="text" maxlength="13" style="width:70%;" class="form_input text_ient" />
                </p>
            </div>

            <div class="p_line text_ient lx-row ptb10">
                <div class="col lx-col-50">
                    <a class="find_a">1寸蓝/白底照片：</a>
                    <p class="img-con front-con">
                        <img src="">
                        <b class="del-img">❌</b>
                    </p>
                    <input id="1cun" type="file" class="input-file" accept="image/*" />
                </div>
                <div class="col lx-col-50">
                    <a class="find_a">2寸蓝/白底照片：</a>
                    <p class="img-con">
                        <img src="">
                        <b class="del-img">❌</b>
                    </p>
                    <input id="2cun" type="file" class="input-file" accept="image/*" />
                </div>
            </div>
        </div>
    </div>

    <div class="lx-section">
        <div class="title">
            第一学历
        </div>
        <div class="p_line text_ient lx-row">
            <p class="col lx-col-33">
                <a class="find_a">学历层次：</a>
             
                <select id="educationName" style="width: 50%;" id="" class="educationLevel select-30 form-control">
                    <option value="">请选择</option>
                </select>
            </p>
            <p class="col lx-col-33">
                <a class="find_a">专业：</a>
                <input id="zhuanye" type="text" class="form_input text_ient"  />
            </p>
            <p class="col lx-col-33">
                <a class="find_a">毕业院校：</a>
                <input id="school" type="text" style="width: 75%" class="form_input text_ient"  />
            </p>
        </div>
        <div class="p_line text_ient lx-row">
            <p class="col lx-col-33">
                <a class="find_a">学习形式：</a>
                <input id="studyMode" type="text" style="width: 75%" class="form_input text_ient"  />
            </p>
            <p class="col lx-col-33">
                <a class="find_a">证书编号：</a>
                <input id="certificateNumber" type="text" style="width: 75%" class="form_input text_ient"  />
            </p>
            <p class="col lx-col-33">
                <a class="find_a">毕业时间：</a>
                <input id="time" type="date" style="width: 75%" class="form_input text_ient"  />
            </p>
        </div>
        <div class="p_line text_ient lx-row ptb10">
            <div class="col lx-col-33">
                <a class="find_a">毕业证：</a>
                <p class="img-con front-con">
                    <img src="">
                    <b class="del-img">❌</b>
                </p>
                <input id="biyezheng1" type="file" class="input-file" accept="image/*" />
            </div>
            <div class="col lx-col-33">
                <a class="find_a">学位证：</a>
                <p class="img-con">
                    <img src="">
                    <b class="del-img">❌</b>
                </p>
                <input id="xueweizheng1"  type="file" class="input-file" accept="image/*" />
            </div>
            <div class="col lx-col-33">
                <a class="find_a">电子注册表：</a>
                <p class="img-con">
                    <img src="">
                    <b class="del-img">❌</b>
                </p>
                <input id="zhucebiao1" type="file" style="width: 65%" class="input-file" accept="image/*" />
            </div>
        </div>
    </div>

    <div class="lx-section">
        <div class="title">
            第二学历
        </div>
        <div class="p_line text_ient lx-row">
            <p class="col lx-col-33">
                <a class="find_a">学历层次：</a>
                <select id="educationName2" style="width: 50%;" class="educationLevel select-30 form-control">
                    <option value="">请选择</option>
                </select>
            </p>
            <p class="col lx-col-33">
                <a class="find_a">专业：</a>
                <input id="zhuanye2" type="text" class="form_input text_ient" placeholder="" />
            </p>
            <p class="col lx-col-33">
                <a class="find_a">毕业院校：</a>
                <input id="school2" type="text" style="width: 75%" class="form_input text_ient" placeholder="" />
            </p>
        </div>
        <div class="p_line text_ient lx-row">
            <p class="col lx-col-33">
                <a class="find_a">学习形式：</a>
                <input id="studyMode2" type="text" style="width: 75%" class="form_input text_ient" placeholder="" />
            </p>
            <p class="col lx-col-33">
                <a class="find_a">证书编号：</a>
                <input id="certificateNumber2" type="text" style="width: 75%" class="form_input text_ient" placeholder="" />
            </p>
            <p class="col lx-col-33">
                <a class="find_a">毕业时间：</a>
                <input id="time2" type="date" style="width: 75%" class="form_input text_ient" placeholder="" />
            </p>
        </div>
        <div class="p_line text_ient lx-row ptb10">
            <div class="col lx-col-33">
                <a class="find_a">毕业证：</a>
                <p class="img-con front-con">
                    <img src="">
                    <b class="del-img">❌</b>
                </p>
                <input id="biyezheng2" type="file" class="input-file" accept="image/*" />
            </div>
            <div class="col lx-col-33">
                <a class="find_a">学位证：</a>
                <p class="img-con">
                    <img src="">
                    <b class="del-img">❌</b>
                </p>
                <input id="xueweizheng2"  type="file" class="input-file" accept="image/*" />
            </div>
            <div class="col lx-col-33">
                <a class="find_a">电子注册表：</a>
                <p class="img-con">
                    <img src="">
                    <b class="del-img">❌</b>
                </p>
                <input id="zhucebiao2" type="file" style="width: 65%" class="input-file" accept="image/*" />
            </div>
        </div>
    </div>

    <div class="lx-section">
        <div class="title">
            证书信息
        </div>
        <div class="p_line text_ient lx-row">
            <div class="col lx-col-50 lx-zheng">
                <a class="find_a">证书：</a>
                <input type="text" class="form_input text_ient" placeholder="" />
                <p class="img-con">
                    <img src="">
                    <b class="del-img">❌</b>
                </p>
                <input id="zh1" type="file" class="input-file" accept="image/*" />
            </div>
            <div class="col lx-col-50 lx-zheng">
                <a class="find_a">证书：</a>
                <input type="text" class="form_input text_ient" placeholder="" />
                <p class="img-con">
                    <img src="">
                    <b class="del-img">❌</b>
                </p>
                <input id="zh2" type="file" class="input-file" accept="image/*" />
            </div>
        </div>
        <div class="p_line text_ient lx-row ptb10">
            <div class="col lx-col-50 lx-zheng">
                <a class="find_a">证书：</a>
                <input type="text" class="form_input text_ient" placeholder="" />
                <p class="img-con">
                    <img src="">
                    <b class="del-img">❌</b>
                </p>
                <input id="zh3" type="file" class="input-file" accept="image/*" />
            </div>
            <div class="col lx-col-50 lx-zheng">
                <a class="find_a">证书：</a>
                <input type="text" class="form_input text_ient" placeholder="" />
                <p class="img-con">
                    <img src="">
                    <b class="del-img">❌</b>
                </p>
                <input id="zh4" type="file" class="input-file" accept="image/*" />
            </div>
        </div>
    </div>

    <div class="lx-section" style="display: none;" id="xueli_div" >
        <div class="title">
            学历报考信息
        </div>
        <div class="lx-row">
        </div>
    </div>

    <div class="lx-section"  style="display: none;" id="zhiye_div">
        <div class="title">
            职业报考信息
        </div>
        <div class="lx-row">
            
        </div>
    </div>

    <div class="lx-section"  style="display: none;" id="zhicheng_div">
        <div class="title">
            职称报考信息
        </div>
        <div class="lx-row">
            
        </div>
    </div>

    <div class="lx-section" style="display: none;" id="peixun_div">
        <div class="title">
            培训报考信息
        </div>
        <div class="lx-row">
            
        </div>
    </div>

    <div id="xueli" style="display: none;">
    </div>

    <div id="zhiye" style="display: none;">
    
</div>
    <div id="zhicheng" style="display: none;">
    
</div>
    <div id="peixun" style="display: none;">
    
</div>



<div id="buttons" style="display: none; text-align:center;margin-bottom:30px">
    <button class="a_add" id="save">修改</button>
    <button class="a_add" id="submit">提交</button>
</div>

    <div class="big-img" style="display:none">
        <img src="" alt="">
    </div>

    <script src="../../../js/jquery.js"></script>
    <script src="../../../js/common.js"></script>
    <script src="../../../layer_v2.1/layer/layer.js"></script>
    <script src="../../../bstable/js/bootstrap-table.js"></script>
    <script src="../../../bstable/js/bootstrap-table-zh-CN.min.js"></script>
    <script src="../../../js/laydate-master/laydate.js"></script>
    <script src="./otherInfoEdit.js"></script>
    <script src="./register-info.js"></script>

    <script>
        function handleBack() {
          window.location.href = '../hotel/studentSearch.html';
        }

        function getQuery(variable) {
            var query = window.location.search.substring(1);
            var vars = query.split("&");
            for (var i = 0; i < vars.length; i++) {
                var pair = vars[i].split("=");
                if (pair[0] == variable) {
                    return pair[1];
                }
            }
            return (false);
        }

        var flag = getQuery('flag')
        var feeId = ''

        if (getQuery('from') === 'student') {
            localStorage.setItem('name', '学生管理/学生信息查询/修改')
          } else if (getQuery('from') === 'jiaowu') {
            localStorage.setItem('name', '教务管理/教务信息管理/修改')
          } else if (getQuery('from') === 'jiaofei') {
            localStorage.setItem('name', '财务管理/缴费信息管理/修改')
          } else if (getQuery('from') === 'fenqi') {
            localStorage.setItem('name', '学生管理/分期缴费信息查询/修改')
          }
        
        window.mobile = JSON.parse(localStorage.getItem('userInfo')).mobile.slice(7);

        function querySchool(obj) {
            $.ajax({
                url: baseUrl + "education/querySchoolList",
                method: "Post",
                data: "educationId=" + obj.value,
                headers: {
                        "Authorization": JSON.parse(localStorage.getItem('userInfo')).token
                    },
                success: function (data) {
                    var html_ = "<option value=\"0\">请选择</option>";
                    for (var i = 0; i < data.length; i++) {
                        html_ += "<option value=\"" + data[i].id + "\" >" + data[i].schoolName +
                            "</option>";
                    }
                    $(obj).parent().find('.myschool').html(html_);
                }
            })
        }

        function getUserInfo(idNo, type, studyId) {
            $.ajax({
                url: baseUrl + "studentInfo/getStudentInfo",
                method: "get",
                headers: {
                    "Authorization": JSON.parse(localStorage.getItem('userInfo')).token
                },
                data: {
                    idNo: idNo,
                    trainType: type,
                    studyId,
                },
                success: function(data) {
                    if (!data.student) {
                        return alert('未找到对应的数据');
                    }
					
                    var fees = data.fees
                    window.fees = fees;
                    var student = data.student
                    var education = data.studentEducation
                    var train = data.studentTrain
                    var title = data.studentTitle
                    var occu = data.studentOccupation
                    var id1, id2, id3, id4;
                    window.feesId = fees.map((item) => item.id);
                    window.uploadId = student.id
                    // 每个页面只有一条对应的报考信息，将这条信息保存在window上，用来修改

                    window.bkInfo = education || occu || title || train;

                    showImg(data.studentCards)
                    
                    $('#buttons').show();
                    if (getQuery('type') === 'baokao') {
                        $('#save').hide();
                    }

                    // education,train,title,occupation
                    // 根据报考类型来修改对应的内容
                    if (type == 'education' && education.length !== 0) {
                      var registerInfo = new RegisterInfo(type);
                      registerInfo.initEditEducations(education, fees).then(({ infoDom, feeDom }) => {
                        $('#xueli_div').show();
                        $('#xueli_div .lx-row').html(infoDom);
                        $('#xueli').show();
                        $('#xueli').html(feeDom);
                        $('#xueli .fee').show();
                      });
                    }

                    if (type == 'occupation') {
                      let registerInfo = new RegisterInfo(type);
                      let educationObj = registerInfo.initEditOccupations(occu, fees).then(( { infoDom, feeDom } ) => {
                        $('#zhiye_div').show()
                        $('#zhiye_div .lx-row').html(infoDom);
                        $('#zhiye').show();
                        $('#zhiye').html(feeDom);
                        $('#zhiye .fee').show();
                      });
                    }

                    if (type == 'title') {
                      let registerInfo = new RegisterInfo(type);
                      let educationObj = registerInfo.initEditTitles(title, fees).then(({ infoDom, feeDom }) => {
                        $('#zhicheng_div').show()
                        $('#zhicheng_div .lx-row').html(infoDom);
                        $('#zhicheng').show();
                        $('#zhicheng').html(feeDom);
                        $('#zhicheng .fee').show();
                      })
                    }

                    if (type == 'train') {
                      let registerInfo = new RegisterInfo(type);
                      let educationObj = registerInfo.initEditTrains(train, fees).then(({ infoDom, feeDom }) => {
                        $('#peixun_div').show()
                        $('#peixun_div .lx-row').html(infoDom);
                        $('#peixun').show();
                        $('#peixun').html(feeDom);
                        $('#peixun .fee').show();
                      })
                    }

                    $('#name').val(student.name)
                    $('#phone').val(student.phoneNum)
                    $('#idno').val(student.idNo)
                    $('#nation').val(student.nation)
                    $('#sex').val(student.sex)
                    $('#birth').val(student.birthday)
                    $('#address').val(student.address)
                    $('#email').val(student.email);
                    $('#qq').val(student.qqNumber);
                    $('#company').val(student.workAdress);

                    // 第一学历
                    $('#zhuanye').val(student.major);
                    $('#educationName option').each(function() {
                        if ($(this).text() == student.educationName) {
                            $(this).prop('selected', true)
                        }
                    })
                    $('#school').val(student.graduateSchool);
                    $("#studyMode").val(student.studyMode);
                    $("#certificateNumber").val(student.certificateNumber);
                    $('#time').val(student.graduateTime);
                    
                    // 第二学历
                    $('#zhuanye2').val(student.major2);
                    $('#educationName2 option').each(function() {
                        if ($(this).text() == student.educationName2) {
                            $(this).prop('selected', true)
                        }
                    })
                    $('#school2').val(student.educationName2);
                    $("#studyMode2").val(student.studyMode2);
                    $('#time2').val(student.graduateTime2);
                    $("#certificateNumber2").val(student.certificateNumber2);

                    // if(train!="undefined"){
                    //     $('#start').val(train.startDate);
                    //     $('#end').val(train.endDate);
                    // }
                }
            })
        }

        function showImg(list) {
            if (!list.length) return
            var maps = ['id-front', 'id-back', 'byz', 'xwz'],
                maps1 = ['1cun', '2cun', 'biyezheng1', 'xueweizheng1', 'zhucebiao1', 'biyezheng2', 'xueweizheng2', 'zhucebiao2'],
                maps2 = ['jiaofei', 'youhui', 'qita'],
            zh1, zh2, zh3, zh4, id;
            list.forEach(function(item, index) {
                if (maps.includes(item.property)) {
                    $('#' + item.property).hide()
                    $('#' + item.property).siblings('p').css('display', 'inline-block').find('img').attr('src',
                        baseUrl + 'studentInfo/picDownload?url=' + encodeURIComponent(item.fileResource))
                } else if (maps1.includes(item.property)) {
                    console.log(item)
                    $('#' + item.property).siblings('p').css('display', 'inline-block').find('img').attr('src', baseUrl +
                        'studentInfo/picDownload?url=' + encodeURIComponent(item.fileResource))
                }else if(maps2.includes(item.property)){
                    $('#' + item.property).attr('src', baseUrl +
                        'studentInfo/picDownload?url=' + encodeURIComponent(item.fileResource)).parents('.pz1').css({'display': 'inline-block'})
                } else {
                    console.log(zh1, 11, item)
                    if (!zh1) {
                        id = 'zh1'
                        zh1 = 1
                    } else if (!zh2) {
                        id = 'zh2'
                        zh2 = 1
                    } else if (!zh3) {
                        zh3 = 1
                        id = 'zh3'
                    } else {
                        zh4 = 1
                        id = 'zh4'
                    }
                    $('#' + id).hide()
                    console.log(id)
                    $('#' + id).siblings('p').css('display', 'inline-block').find('img').attr('src', baseUrl +
                        'studentInfo/picDownload?url=' + encodeURIComponent(item.fileResource))
                    $('#' + id).siblings('input').val(item.property)
                }
            })
        }

        function showFee(self, selector) {
            console.log(self.value);
            if(self.value != 0 ) {
                $(selector).show().attr('data-show', 'show')
            }else {
                $(selector).hide().removeAttr('data-show')
            }
        }

        function queryCourse(obj, idx) {
            $.ajax({
                url: baseUrl + "education/queryCourseList",
                method: "Post",
                data: "schoolId=" + obj.value,
                headers: {
                    "Authorization": JSON.parse(localStorage.getItem('userInfo')).token
                },
                success: function (data) {
                    var html_ = "<option value=\"0\">请选择</option>";
                    for (var i = 0; i < data.length; i++) {
                        html_ += "<option  value=\"" + data[i].id + "\" >" + data[i].courseName +
                            "</option>";
                    }
                    // $(obj).parent().find('.mycourse').html(html_);
                    $(obj).next().next().html(html_);
                }
            })
        }

        function queryXLBatch(obj) {
            $.ajax({
                url: baseUrl + "education/queryBatchList",
                method: "Post",
                data: {
                    pid: $(obj).val(),
                    trainType: 'education',
                },
                success: function (data) {
                    var html_ = "<option value=\"0\">请选择</option>";
                    for (var i = 0; i < data.length; i++) {
                        html_ += "<option  value=\"" + data[i].id + "\" >" + data[i].batch +
                            "</option>";
                    }
                    $("#xl-pc").html(html_);
                }
            })
        }

        function queryOccupation(obj, idx) {
            $.ajax({
                url: baseUrl + "education/queryOccupationInfoList",
                method: "Post",
                headers: {
                        "Authorization": JSON.parse(localStorage.getItem('userInfo')).token
                    },
                data: "occupationId=" + obj.value,
                success: function (data) {
                    var html_ = "<option value=\"0\">请选择</option>";
                    for (var i = 0; i < data.length; i++) {
                        html_ += "<option  value=\"" + data[i].id + "\" >" + data[i].occupationInfoName +
                            "</option>";
                    }
                    $(obj).next().next().html(html_);
                    
                    //alert(data[0].educationName);
                }
            })

        }

        function queryTrain(obj, idx) {
            $.ajax({
                url: baseUrl + "education/queryTrainInfoList",
                method: "Post",
                headers: {
                        "Authorization": JSON.parse(localStorage.getItem('userInfo')).token
                    },
                data: "trainId=" + obj.value,
                success: function (data) {
                    var html_ = "<option value=\"0\">请选择</option>";
                    for (var i = 0; i < data.length; i++) {
                        html_ += "<option  value=\"" + data[i].id + "\" >" + data[i].trainInfoName +
                            "</option>";
                    }
                    $(`#examCourse${idx}`).html(html_);
                }
            })

        }

        // var pageFrom = ''
        if (getQuery('from')) {
            var from = getQuery('from')
            var id = getQuery('id')
            var type = getQuery('type')
            var trainType = getQuery('trainType')
            var idNo = getQuery('idNo')
            var studyId = getQuery('studyId')
            // pageFrom = from
            
            setTimeout(() => {
                getUserInfo(idNo, trainType, studyId)
            }, 500);
        }

        function bigShow(src) {
            $('.big-img img').attr('src', src)
            $('.big-img').show()
        }
        $('.big-img').on('click', function() {
            $('.big-img').hide()
        })

        $('.img-con img').on('click', function() {
            var src = $(this).attr('src')
            if(src.endsWith('pdf')) {
                src = encodeURIComponent(location.origin + src)
                window.open('../../pdf/web/viewer.html?file=' + src);
            }else {
                bigShow(src)
            }
        })
    </script>
</body>

</html>